import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '分类名称',
    align: 'center',
    dataIndex: 'categoryName',
  },
  {
    title: '分类图片',
    align: 'center',
    dataIndex: 'categoryPicture',
    customRender: render.renderImage,
  },
  {
    title: '父级分类',
    align: 'center',
    dataIndex: 'parentCategory_dictText',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '分类名称',
    field: 'categoryName',
    component: 'Input', //TODO 范围查询
    //colProps: {span: 6},
  },
  {
    label: '父级分类',
    field: 'parentCategory',
    component: 'JTreeSelect',
    componentProps: {
      dict: 'uf_mall_goods_category,category_name,id',
      pidField: 'parent_category',
    },
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '分类名称',
    field: 'categoryName',
    component: 'Input',
  },
  {
    label: '分类图片',
    field: 'categoryPicture',
    component: 'JImageUpload',
    componentProps: {
      fileMax: 0,
    },
  },
  {
    label: '父级分类',
    field: 'parentCategory',
    component: 'JTreeSelect',
    componentProps: {
      dict: 'uf_mall_goods_category,category_name,id',
      pidField: 'parent_category',
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  categoryName: { title: '分类名称', order: 0, view: 'text', type: 'string' },
  categoryPicture: { title: '分类图片', order: 1, view: 'image', type: 'string' },
  parentCategory: {
    title: '父级分类',
    order: 2,
    view: 'sel_tree',
    type: 'string',
    pidValue: 'category_parent',
  },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
